package com.haoran.grope.server;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class CalculatorServer {

	@RabbitListener(queues = "amqp-sum")
	public int sum(int[] arr) {
		if (arr == null || arr.length == 0) {
			return 0;
		} else {
			int a = 0;
			for (int i = 0; i < arr.length; i++) {
				a += arr[i];
			}
			return a;
		}
	}
	
	
	@RabbitListener(queues = "amqp-msg")
    public String processMessage(String msg) {
        System.out.println(Thread.currentThread().getName() + " 接收到来自hello.queue1队列的消息：" + msg);
        return msg.toUpperCase();
    }
 
}
